#include <iostream>
#include <cstdio>

using namespace std;

inline long long ckjread()
{
	long long s=0,w=1,ch=getchar();
	while(ch<'0'||ch>'9') ch=='-'?w=-1,ch=getchar():ch=getchar();
	while(ch>='0'&&ch<='9') s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return s*w;
}

void jynwriten(long long x)
{
	x>9?jynwriten(x/10),putchar(x%10|48):putchar(x|48);
}

struct node
{
	int frt,nxt;
	int val,id;
}lis[200005];

int n;
int a[200005],ans[200005];
int blo,bloid[200005],tmpbloid[200005];
int cnt,head[200005],tail[200005];

int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	n=ckjread();
	a[0]=-1;
	for(int i=1;i<=n;i++)
	{
		a[i]=ckjread();
		if(a[i]!=a[i-1])
		{
			blo++;
			bloid[blo]=blo;
			head[blo]=++cnt;
			tail[blo]=cnt;
			lis[cnt].val=a[i];
			lis[cnt].id=i;
			lis[cnt].frt=-1;
			lis[cnt].nxt=-1;
		}
		else
		{
			lis[++cnt].val=a[i];
			lis[cnt].id=i;
			lis[cnt].frt=tail[blo];
			lis[cnt].nxt=-1;
			lis[tail[blo]].nxt=cnt;
			tail[blo]=cnt;
		}
	}
	int left=n;
	while(left>0)
	{
		left-=blo;
		int las=-1;
		int newblo=0,nowanscnt=0;
		for(int i=1;i<=blo;i++)
		{
			int id=bloid[i];
			ans[++nowanscnt]=lis[head[id]].id;
			if(lis[head[id]].nxt!=-1)
			{
				head[id]=lis[head[id]].nxt;
				if(las!=-1&&lis[head[las]].val==lis[head[id]].val)
				{
					lis[tail[las]].nxt=head[id];
					lis[head[id]].frt=tail[las];
					tail[las]=tail[id];
				}
				else
				{
					tmpbloid[++newblo]=id;
					las=id;
				}
			}
		}
		blo=newblo;
		for(int i=1;i<=blo;i++)
		{
			bloid[i]=tmpbloid[i];
		}
		for(int i=1;i<nowanscnt;i++)
		{
			jynwriten(ans[i]);
			putchar(' ');
		}
		jynwriten(ans[nowanscnt]);
		putchar('\n');
	}
	return 0;
}
